<template>
  <div>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.id">
        <router-link :to="'/home/NewsInfo/'+item.id">
          <!-- <a href="javascript:;"> -->
          <img class="mui-media-object mui-pull-left" :src="item.pic" />
          <div class="mui-media-body">
            <!-- <h4 @click="jump(item.url)">{{item.title}}</h4> -->
            <h4>{{item.title}}</h4>
            <p class="mui-ellipsis">
              <span>发表时间：{{item.dateAdd | dataFormat}}</span>
              <span>点击次数：{{item.id}}</span>
            </p>
          </div>
          <!-- </a> -->
        </router-link>
      </li>
    </ul>
  </div>
</template>


<script>
import { Toast } from "mint-ui";

export default {
  data() {
    return {
      newsList: []
    };
  },
  created() {
    this.getNewsList();
  },
  methods: {
    getNewsList() {
      this.$http.get("https://api.it120.cc/pp/cms/news/list").then(result => {
        // console.log(result)
        if (result.body.code === 0) {
          this.newsList = result.body.data;
        } else {
          Toast("加载新闻失败");
        }
      });
    }

    //   jump(url) {
    //     window.location.href = url;
    //   }
  }
};
</script>

<style lang="scss" scoped>
.mui-table-view {
  li {
    h4 {
      font-size: 14px;
    }
    .mui-ellipsis {
      font-size: 12px;
      color: #226aff;
      // 文字两端对齐
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>